package main

import (
	"fmt"
	"strings"
)

func main() {
	// 字符串拼接
	s1 := `C:\Users\v_diweiliao\Desktop\Go\src\gitee.com`
	fmt.Println(len(s1))

	s2 := "zhihuan"
	s3 := "name:"
	s4 := s3 + s2 // 加好拼接
	fmt.Println(s4)
	fmt.Printf("%s%s\n", s3, s2) // 占位符拼接
	ss := fmt.Sprintf("%s%s", s3, s2)
	fmt.Println(ss)

	// 字符串分割
	ret := strings.Split(s1, "\\")
	fmt.Println(ret)

	// 判断包含
	fmt.Println(strings.Contains(s1, "Go"))
	fmt.Println(strings.Contains(s1, "Java"))

	// 前缀
	fmt.Println(strings.HasPrefix(s1, "C"))
	// 后缀
	fmt.Println(strings.HasSuffix(s1, "src"))

	// 获取字符串下标
	str := "abcbasdb"
	fmt.Println(strings.Index(str, "b"))
	fmt.Println(strings.LastIndex(str, "b"))

	// 拼接
	fmt.Println(strings.Join(ret, "~"))
}
